/***********************
 * Inquiry Stats Panel
 */
AIR2.Inquiry.Stats = function() {
    return new AIR2.UI.Panel({
        colspan: 1,
        title: 'Statistics',
        iconCls: 'air2-icon-stats',
        storeData: AIR2.Inquiry.STATSDATA,
        tpl: new Ext.XTemplate(
            '<tpl for=".">' +
             '<ul class="air2-inquiry-source">' +
              '<li><h2><a href="'+AIR2.HOMEURL+'/search/responses/?q=inq_uuid_title%3d{inq_uuid}">{SubmissionCount} Submissions</a></h2>' +
                '<span>{[this.formatResponseRate(values.SubmissionRate)]}</span></li>' +
              '<li><h2><a href="'+AIR2.HOMEURL+'/search/sources/?q=inq_uuid_title%3d{inq_uuid}">{SourceCount} Sources</a></h2>' +
                '<span>{[this.formatSourceRate(values.SourceRate)]}</span></li>' +
              '</ul>' +
            '</tpl>',
            {
                compiled:true,
                disableFormats:true,
                formatResponseRate: function(rate) {
                    if (isNaN(rate))
                        return 'Response Rate Not Available';
                    var pct = Math.round(rate*1000) / 10;
                    return pct + '% Response Rate';
                },
                formatSourceRate: function(rate) {
                    if (isNaN(rate))
                        return 'Rate Not Available';
                    var pct = Math.round(rate*1000) / 10;
                    return pct + '% of the PIN';
                }
            }
        )
        
    });
}
